package com.tedu.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(urlPatterns = "/LoginServlet")
public class LoginServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;utf-8");
        String user = req.getParameter("username");
        String psw = req.getParameter("psw");
        if (user.equalsIgnoreCase("admit")&&psw.equals("111")){
            String url="http://http://localhost:8080/UserSystem_war/index.html";
            resp.sendRedirect(url);
        }else{
           /* resp.setContentType("gbk");*/
            String info="用户名或密码错误,请重新输入!";
            String loginurl="http://http://localhost:8080/UserSystem_war/login.html";
            resp.getWriter().println(info+"<br/>"+"<a href='"+loginurl+"'>去登录</a>");

        }

    }
}
